from django.db import models

from apps.aiauth.models import Users
from apps.career.models import Careerplan
from apps.resume.models import Resume
from apps.setup.models import Experts


class Message(models.Model):
    message_id = models.BigAutoField(primary_key=True, db_column='message_id')
    to_id = models.BigIntegerField(blank=True, null=True, db_column='to_id')
    from_field = models.ForeignKey(Users, models.DO_NOTHING, db_column='from_id', blank=True, null=True)
    type = models.IntegerField(blank=True, null=True)
    content = models.CharField(max_length=120, blank=True, null=True)
    jumpurl = models.CharField(max_length=50, blank=True, null=True)
    isread = models.BooleanField()
    create_time = models.DateTimeField(blank=True, null=True)
    update_time = models.DateTimeField(blank=True, null=True)

    class Meta:
        db_table = 'message'
        verbose_name_plural = '消息通知表'


class Comments(models.Model):
    comments_id = models.BigAutoField(primary_key=True, db_column='comments_id')
    careerplan_id = models.ForeignKey(Careerplan, models.DO_NOTHING, blank=True, null=True, db_column='careerplan_id')
    resume_id = models.ForeignKey(Resume, models.DO_NOTHING, blank=True, null=True, db_column='resume_id')
    type = models.IntegerField(blank=True, null=True)
    # type 0是简历， 1是规划
    user_id = models.ForeignKey(Users, models.DO_NOTHING, blank=True, null=True, db_column='user_id')
    experts_id = models.ForeignKey(Experts, models.DO_NOTHING, blank=True, null=True, db_column='experts_id')
    parent_id = models.IntegerField(blank=True, null=True, db_column='parent_id')
    content = models.TextField(blank=True, null=True)
    content_json = models.TextField(blank=True, null=True)
    is_author = models.BooleanField(blank=True, null=True)
    create_time = models.DateTimeField()
    update_time = models.DateTimeField(blank=True, null=True)
    status = models.IntegerField(blank=True, null=True, default=1)

    # status 1为正常，0为删除，2仅老师可见，默认1

    class Meta:
        db_table = 'comments'
        verbose_name_plural = '规划、简历-评论表'
